class Solution {
public:
    string baseNeg2(int n)
    {
        if (n == 0 || n == 1) return to_string(n);
        string ans;
        while (n != 0)
        {
            int t = n & 1;
            ans += t + '0';
            n -= t;
            n /= -2;
        }
        ranges::reverse(ans);
        return ans;
    }
};